package org.sample.springboot.verifier;

import org.sample.springboot.model.Account;
import org.sample.springboot.model.Address;
import org.sample.springboot.model.Contact;

import java.util.function.Consumer;

import static org.junit.Assert.assertEquals;

public class AccountVerifier extends Verifier<Account> {

	private AccountVerifier() {

	}

	public static interface AccountPropVerifier extends Consumer<Account> {

	}

	public static AccountVerifier expect(AccountPropVerifier... propVerifiers) {
		AccountVerifier verifier = new AccountVerifier();
		verifier.propVerifiers = propVerifiers;
		return verifier;
	}

	public static AccountPropVerifier id(int id) {
		return obj -> assertEquals(id, obj.getId());
	}

	public static AccountPropVerifier home(Verifier<Address> homeVerifier) {
		return obj -> homeVerifier.verify(obj.getHome());
	}

	@SafeVarargs
	public static AccountPropVerifier contactList(Verifier<Contact>... contactVerifiers) {
		return obj -> verifyList(contactVerifiers, obj.getContactList());
	}

}
